#{extends 'main.html' /}
<head>
<script type="text/javascript"
	src="/public/javascripts/jquery.tokeninput.js"></script>
<link rel="stylesheet" type="text/css"
	href="/public/stylesheets/token-input-facebook.css" />
<link rel="stylesheet" type="text/css"
	href="/public/stylesheets/token-input.css" />
<script type="text/javascript"
	src="@{'/public/javascripts/calendar-2.2.js'}"></script>

</head>

<link rel="stylesheet" type="text/css"
	href="@{'/public/stylesheets/jquery.autocomplete.css'}" />
<script type="text/javascript"
	src="@{'/public/javascripts/jquery.autocomplete.js'}"></script>
<script type="text/javascript">
	//$(init);
	function init() {
		$("#allLabel").onclick(function() {
			$("#allLabel").fadeOut();
		});

	}
	function applyF() {
		$("#srchLoc").fadeOut();
	}
	function uncheckAllBox(caller) {

		//$("#choose-all-locations").checked = false;
		//form = document.forms[0];
		//alert(caller.id);
		if (caller.id == "choose-all-locations") {
			document.getElementById("inIdeas").checked = true;
			document.getElementById("inTopics").checked = true;
			document.getElementById("inPlans").checked = true;
			document.getElementById("inEntities").checked = true;
			document.getElementById("inOrganizations").checked = true;
			document.getElementById("inIdeaContent").checked = false;
			document.getElementById("inTopicDescription").checked = false;
		}
		if (caller.id != "inTopicDescription" || caller.id != "inIdeaContent") {
			if (caller.id != "inTopicDescription"
					&& document.getElementById("inTopics").checked) {
				document.getElementById('inTopicDescription').checked = false;
			} else if (caller.id != 'inIdeaContent'
					&& document.getElementById("inIdeas").checked) {
				document.getElementById('inIdeaContent').checked = false;
			}
		}
		if (caller.id != "inTopics" || caller.id != "inIdeas") {
			if (caller.id != "inTopics"
					&& document.getElementById('inTopicDescription').checked) {
				document.getElementById("inTopics").checked = false;
			}
			if (caller.id != "inIdeas"
					&& document.getElementById('inIdeaContent').checked) {
				document.getElementById("inIdeas").checked = false;
			}
		}
		var allChecked = true;
		//alert($("#inIdeas").value + " , " + $("#inIdeas").name + " ," + $("#inIdeas").id);
		//alert($("#inTopics").checked);
		allChecked = document.getElementById("inIdeas").checked
				&& document.getElementById("inTopics").checked
				&& document.getElementById("inPlans").checked
				&& document.getElementById("inEntities").checked
				&& document.getElementById("inOrganizations").checked;
		//alert(allChecked);
		if (allChecked) {
			document.advForm.specifyLocation[0].checked = true;
		} else {
			document.advForm.specifyLocation[1].checked = true;
		}

		//alert(allChecked);
		//$("#choose-all-locations").checked = false;
		//$("#choose-specific-locations").checked = "checked";
		//form.radios[1].checked = true;
		//$("#srchLoc").fadeOut();
		//	if()
	}
</script>
<h2 align="left">Advanced Search..</h2>
#{form @Browse.advancedSearch(), id:'advForm', name:'advForm' }

<label for="all" id="allLabel" onclick="applyF();">with all of
	the words</label>
<input type="text" name="all" id="all" />
<br />
<label for="exactPhrase">with the exact phrase</label>
<input type="text" name="exactPhrase" id="exactPhrase" />
<br />
<label for="atleast">with at least one of the words</label>
<input type="text" name="atleast" id="atleast" />
<br />
<label for="without">without the words</label>
<input type="text" name="without" id="without" />
<br />
<label for="tag">with the tag</label>
<input type="text" name="tag" id="tag" />
<br />
<p>
	<label for="stDate">Choose start date for posting of results </label> <input
		class="stDate" type="text" name="stDate" id="stDate"></input>
	<script type="text/javascript" charset="utf-8">
		$(".stDate").datepicker({
			dateFormat : 'yy-mm-dd',
			showAnim : 'fadeIn'
		})
	</script>
</p>
<p>
	<label for="endDate">Choose end date for posting of results </label> <input
		class="endDate" type="text" name="endDate" id="endDate"></input>
	<script type="text/javascript" charset="utf-8">
		$(".endDate").datepicker({
			dateFormat : 'yy-mm-dd',
			showAnim : 'fadeIn'
		})
	</script>
</p>
<h3 id="srchLoc" align="left">Search Locations</h3>

<input id="choose-all-locations" type="radio" name="specifyLocation"
	value="all" checked="checked" onclick="uncheckAllBox(this);" />
<label for="choose-all-locations">Search all possible locations</label>
<br />

<div id="specificDiv">

	<input id="choose-specific-locations" type="radio"
		name="specifyLocation" value="specific" /> <label
		for="choose-specific-locations">Search the following Locations
		Only</label> <br /> <input id="inIdeas" type="checkbox" name="inIdeas"
		onchange="uncheckAllBox(this);" /> <label for="inIdeas">Search
		in Ideas</label> <input id="inIdeaContent" type="checkbox"
		name="inIdeaContent" onchange="uncheckAllBox(this);" /> <label
		for="inIdeaContent">Search in Ideas Content Only</label> <br /> <input
		id="inTopics" type="checkbox" name="inTopics"
		onchange="uncheckAllBox(this);" /> <label for="inTopics">Search
		in Topics</label> <input id="inTopicDescription" type="checkbox"
		name="inTopicDescription" onchange="uncheckAllBox(this);" /> <label
		for="inTopicDescription">Search in Topic Description Only</label> <br />
	<input id="inPlans" type="checkbox" name="inPlans"
		onchange="uncheckAllBox(this);" /> <label for="inPlans">Search
		in Plans</label> <br /> <input id="inEntities" type="checkbox"
		name="inEntities" onchange="uncheckAllBox(this);" /> <label
		for="inEntities">Search in Entities</label> <br /> <input
		id="inOrganizations" type="checkbox" name="inOrganizations"
		onchange="uncheckAllBox(this);" /> <label for="inOrganizations">Search
		in Organizations</label>

</div>
<input type="submit" value="Search">

#{/form}
<script type="text/javascript">
	$(document).ready(function() {
		$("#tag").tokenInput("@{Browse.searchTag(q)}", {
			theme : "facebook"
		});
	});
</script>